#!/usr/local/bin/python
# -*- coding: utf-8 -*-

import datetime
from flask import Flask, url_for, request, session, render_template, redirect
from json import dumps

from bompy import app
from utils import q, table, login_required, get2parameters, formtable, textinput, unitoptions, designoptions, typeoptions
from model import Design, BOM




@app.route('/finished')
@login_required
@get2parameters
def finished(ID, DA=datetime.datetime.today, QU=1):
    t= table(["Quantity","Unit","ID Parent","Description","Type","ID Child","Description","Type"])
    return render_template("finished.html",t=t , ID = ID, DA=DA, QU=QU)

    
@app.route('/_finished_search')
@get2parameters
def finished_search(ID,QU=1,DA=datetime.datetime.today()):
    def finishedrec(ID,DA=datetime.today(),QU=1):
        a=[]
        
        
        
    #TODO explode this final product with the date and quantity
    results = cursor.fetchall()
    d={}
    d["aaData"]=[]
    finishedrec(ID,DA,QU)
    return dumps(d)
